from my_io.setting import BLOCK_NUM
from loguru import logger

from system.setting import LOG_FILE_LOCATION

logger.remove()
f = open(LOG_FILE_LOCATION, "w", encoding="utf-8")
logger.add(sink=f)


def block_index_valdate(block_index):
    """
    验证block_index是否越界
    :param block_index: block_
    :return:
    """
    if block_index >= BLOCK_NUM:
        logger.error("block_index越界")
        return False
    elif type(block_index) != int:
        logger.error("block_index不是int型")
        return False
    else:
        return True


def index_validate(index, min_limit, max_limit):
    if type(index) != int:
        logger.error("index不是int型")
        return False
    elif index < min_limit:
        logger.error("索引小于最小限定值")
        return False
    elif index > max_limit:
        logger.error("索引大于最大限定值")
        return False
    else:
        return True


def arg_num_validate(num, *args):
    return len(args) == num
